/**
 * @file 登录接口分离
 * @author 叶永鸿
 * @description 将登录表单所需要实现的接口分离出来
 * @date 2021-7-11
 * @LastEditors 叶永鸿
 * @LastEditTime 2021-7-28
 */

import { ref } from "vue";

interface User {
  userName: string;
  password: string;
  role:string;
}

export const loginUser = ref<User>({
  userName: "",
  password: "",
  role:"",
});

interface Rules {
  userName: {
    
    required: boolean;
    message: string;
    trigger: string;
  }[];
  password: ({
    required: boolean;
    message: string;
    trigger: string;
    min?: undefined;
    max?: undefined;
  } | {
    min: number;
    max: number;
    message: string;
    trigger: string;
    required?: undefined;
  })[];
  role:{
    required:boolean;
    message:string;
    trigger:string;
  }[];
}

// 校验规则
export const rules = ref<Rules>({
  userName: [
    {
      required: true,
      message: "请输入用户名",
      trigger: "blur",
    },
  ],
  password: [
    {
      required: true,
      message: "Password could not be empty...",
      trigger: "blur",
    },
    {
      min: 3,
      max: 30,
      message: "Password's length has to be 3 to 30 characters...",
      trigger: "blur",
    },
  ],
  role:[
    {
      required:true,
      message:"请选择用户角色",
      trigger:"blur",
    },
  ],
});